Skip to content

Bump Java version to 25#287

Merged
rashidi merged 11 commits intomasterfrom
java/jdk-25
Sep 27, 2025
Merged

Bump Java version to 25#287
rashidi merged 11 commits intomasterfrom
java/jdk-25

Conversation

@rashidi
Copy link
Copy Markdown
Owner

@rashidi rashidi commented Sep 27, 2025

No description provided.

@rashidi rashidi added the dependencies Pull requests that update a dependency file label Sep 27, 2025
@gemini-code-assist
Copy link
Copy Markdown

Note

Gemini is unable to generate a summary for this pull request due to the file types involved not being currently supported.

@GetMapping("/greet")
public String greet(@RequestParam String greeting) {
return String.format("%s, my name is %s", greeting, properties.name());
return "%s, my name is %s".formatted(greeting, properties.name());

Check warning

Code scanning / CodeQL

Cross-site scripting Medium

Cross-site scripting vulnerability due to a
user-provided value
.

Copilot Autofix

AI 7 months ago

To prevent XSS, all user input included in a response that could ever be interpreted as HTML should be properly escaped or encoded. In this context, even though the method returns a string, and not a rendered HTML template, best practice is to encode/escape the greeting parameter before returning it. The safest and most standard way in Java is to use the StringEscapeUtils.escapeHtml4 utility from Apache Commons Text, which encodes special characters so that any HTML/JavaScript code passed via the user input will not be executed when rendered in a browser.

To implement this fix:

  • Import org.apache.commons.text.StringEscapeUtils at the top.
  • Escape the greeting parameter using StringEscapeUtils.escapeHtml4(greeting) before interpolating/injecting it into the returned string.
  • No change is needed for properties.name() as it's presumably static-safe configuration, but if user-controlled, it should likewise be escaped.

Change placement:

  • File: cloud-jdbc-env-repo/src/main/java/zin/rashidi/boot/cloud/jdbcenvrepo/greet/GreetResource.java
  • Lines: Add an import for StringEscapeUtils and update the response construction in the greet method.

Suggested changeset 2
cloud-jdbc-env-repo/src/main/java/zin/rashidi/boot/cloud/jdbcenvrepo/greet/GreetResource.java

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/cloud-jdbc-env-repo/src/main/java/zin/rashidi/boot/cloud/jdbcenvrepo/greet/GreetResource.java b/cloud-jdbc-env-repo/src/main/java/zin/rashidi/boot/cloud/jdbcenvrepo/greet/GreetResource.java
--- a/cloud-jdbc-env-repo/src/main/java/zin/rashidi/boot/cloud/jdbcenvrepo/greet/GreetResource.java
+++ b/cloud-jdbc-env-repo/src/main/java/zin/rashidi/boot/cloud/jdbcenvrepo/greet/GreetResource.java
@@ -3,6 +3,7 @@
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
+import org.apache.commons.text.StringEscapeUtils;
 
 /**
  * @author Rashidi Zin
@@ -18,7 +19,8 @@
 
     @GetMapping("/greet")
     public String greet(@RequestParam String greeting) {
-        return "%s, my name is %s".formatted(greeting, properties.name());
+        String safeGreeting = StringEscapeUtils.escapeHtml4(greeting);
+        return "%s, my name is %s".formatted(safeGreeting, properties.name());
     }
 
 }
EOF
@@ -3,6 +3,7 @@
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.apache.commons.text.StringEscapeUtils;

/**
* @author Rashidi Zin
@@ -18,7 +19,8 @@

@GetMapping("/greet")
public String greet(@RequestParam String greeting) {
return "%s, my name is %s".formatted(greeting, properties.name());
String safeGreeting = StringEscapeUtils.escapeHtml4(greeting);
return "%s, my name is %s".formatted(safeGreeting, properties.name());
}

}
cloud-jdbc-env-repo/build.gradle.kts
Outside changed files

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/cloud-jdbc-env-repo/build.gradle.kts b/cloud-jdbc-env-repo/build.gradle.kts
--- a/cloud-jdbc-env-repo/build.gradle.kts
+++ b/cloud-jdbc-env-repo/build.gradle.kts
@@ -26,7 +26,9 @@
 }
 
 dependencies {
-    implementation(platform("org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"))
+    implementation(platform("org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion
+    implementation("org.apache.commons:commons-text:1.14.0")
+}"))
 
     implementation("org.springframework.boot:spring-boot-starter-data-jdbc")
     implementation("org.springframework.cloud:spring-cloud-starter-bootstrap")
EOF
@@ -26,7 +26,9 @@
}

dependencies {
implementation(platform("org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"))
implementation(platform("org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion
implementation("org.apache.commons:commons-text:1.14.0")
}"))

implementation("org.springframework.boot:spring-boot-starter-data-jdbc")
implementation("org.springframework.cloud:spring-cloud-starter-bootstrap")
This fix introduces these dependencies
Package Version Security advisories
org.apache.commons:commons-text (maven) 1.14.0 None
Copilot is powered by AI and may make mistakes. Always verify output.
@rashidi rashidi merged commit b4dae3a into master Sep 27, 2025
5 checks passed
@rashidi rashidi deleted the java/jdk-25 branch September 27, 2025 12:05
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
7 Security Hotspots

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants